﻿using System.Threading.Tasks;
using Godot;
using kemocard.Scripts.Common;
using kemocard.Scripts.Module.Battle;
using kemocard.Scripts.MVC;

namespace kemocard.Scripts.Card.Scripts;

public class BaseCardScript
{
    /**
     * Mod可能为null，使用时注意
     */
    protected static BattleModel Mod => GameCore.ControllerMgr.GetControllerModel<BattleModel>(ControllerType.Battle);

    public virtual Task UseCard(BaseBattleCard parent)
    {
        return Task.CompletedTask;
    }

    public virtual void UpdateRealTimeValue(BaseBattleCard parent, ref float result)
    {
    }

    protected static Damage CreateDamageFromOwner(BaseBattleCard parent)
    {
        Damage damage = new()
        {
            User = parent.User,
            Target = parent.Target,
            Role = parent.User.Role,
            Attribute = parent.Attribute,
            Tags = parent.Tags,
            Value = parent.RealTimeValue,
            ChainNum = parent.RealTimeChain,
            CriticalChance = parent.User.CriticalChance,
            CriticalRate = parent.User.CriticalRate,
            AnimUrl = parent.AnimUrl,
        };
        return damage;
    }
}